package org.jash.sportnews2109.ui

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.ObservableInt
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import org.jash.common.mvvm.BaseActivity
import org.jash.sportnews2109.R
import org.jash.sportnews2109.databinding.ActivitySplashBinding
import org.jash.sportnews2109.vm.SplashViewModel

@Route(path = "/news/splash")
class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
    val count by lazy { ObservableInt(5) }
    override fun initView() {
        binding.count = count
    }

    override fun initData() {
        viewModel.countLiveData.observe(this) {
            count.set(it)
            if (it == 0) {
                ARouter.getInstance().build("/news/main")
                    .navigation()
                finish()
            }
        }
        viewModel.start(count.get())
    }


}